import { Injectable, Inject } from '@nestjs/common';
import { Photo } from 'src/model/photo.entity';
import { Result } from 'src/model/result';
import { ResultUtil } from 'src/utils/resultUtil';
import { Repository } from 'typeorm';

@Injectable()
export class PhotoService {
  constructor(
    @Inject('PHOTO_REPOSITORY')
    private readonly photoRepository: Repository<Photo>,
  ) { }

  async findAll(): Promise<Result<Photo[]>> {
    return ResultUtil.success(await this.photoRepository.find());
  }

  async save(photo: Photo): Promise<Result<any>> {
    let result = await this.photoRepository.save(photo)
    console.log(result)
    return ResultUtil.success(result);
  }
}
